package in.blogspot.khurram2java;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.content.Intent;



public class MainActivity extends Activity implements OnItemClickListener { 

	
	
	String[] data; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		
		
	
		data = getResources().getStringArray(R.array.products);
		
		Integer[] imgID = {
				R.drawable.ic_launcher_listbook,
				R.drawable.ic_launcher_checkshelf,
				R.drawable.ic_mem, 
				R.drawable.ic_setting
				
			};
		
		
		

		MyArrayAdapter adap = new MyArrayAdapter(this, data, data, imgID);
		
		ListView lv = (ListView) findViewById(R.id.listView1);
		lv.setAdapter(adap);
		
		lv.setOnItemClickListener(this);
	}
	

    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

    	if(position==0)
    	{
    		Intent addshelve = new Intent(this,AddShelve.class);
    		startActivity(addshelve);
    		
    	} else if(position==1){
    		Intent aototext = new Intent(this,Search.class);
    		startActivity(aototext);
    		
    	}else if(position==2){
    		Intent memo = new Intent(this,Memo.class);
    		startActivity(memo);
    	}
    	else{
    	Toast.makeText(getBaseContext(), 
    		"you choose " + String.valueOf(position) + " " + data[position] , 0).show();  }
    }
	
}	












	



